﻿/////////////////////////////////////////////////
//string extension 
//1、IsPicture jpeg gif jpg png bmp  pic
//2、IsExcel
//3、IsWord
//4、jquery.center()
/////////////////////////////////////////////////


String.prototype.IsPicture = function () {
    var strFilter = ".jpeg|.gif|.jpg|.png|.bmp|.pic|"
    if (this.indexOf(".") > -1) {
        var p = this.lastIndexOf(".");
        var strPostfix = this.substring(p, this.length) + '|';
        strPostfix = strPostfix.toLowerCase();
        if (strFilter.indexOf(strPostfix) > -1) {
            return true;
        }
    }
    return false;
}

String.prototype.IsExcel = function () {
    var strFilter = ".xls|.xlsx"
    if (this.indexOf(".") > -1) {
        var p = this.lastIndexOf(".");
        var strPostfix = this.substring(p, this.length) + '|';
        strPostfix = strPostfix.toLowerCase();
        if (strFilter.indexOf(strPostfix) > -1) {
            return true;
        }
    }
    return false;
}

String.prototype.IsWord = function () {
    var strFilter = ".doc|.docx"
    if (this.indexOf(".") > -1) {
        var p = this.lastIndexOf(".");
        var strPostfix = this.substring(p, this.length) + '|';
        strPostfix = strPostfix.toLowerCase();
        if (strFilter.indexOf(strPostfix) > -1) {
            return true;
        }
    }
    return false;
}

jQuery.fn.center = function () {
    this.css("position", "absolute");
    this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
    this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
    return this;
}


function AjaxOptionsEditFailure() {
    alert('操作失败了T_T！');
}

function AjaxOptionsEditSuccess(res) {
    if (res.success) {
        alert("修改成功");
    }
    else {
        alert(res.message);
    }
}
